make rand.NewSource safe for concurrent use#3
Open
dprittie wants to merge 3 commits intoenvimate:masterfrom
Open
make rand.NewSource safe for concurrent use#3dprittie wants to merge 3 commits intoenvimate:masterfrom
dprittie wants to merge 3 commits intoenvimate:masterfrom
Conversation
added 3 commits
August 21, 2021 10:17
Author
|
@spirius - any chance you can take a look at this? I can see this project has had no activity for quite a few years but you are still active on github so I'm hoping we can fix this here. If not I'll open one on https://github.com/aperum/nrpe, though I suspect I will run into the same issue. Maybe I'll end up creating another fork and getting that into https://github.com/RobustPerception/nrpe_exporter. |
Member
|
Hey @dprittie! Thanks for your contribution. I personally won't be maintaining the repo, so I suggest you open the PR against https://github.com/spirius/nrpe and I will write in the README that moving forward https://github.com/spirius/nrpe is the main fork. That is if @spirius is ready to continue maintaining this? Cheers, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I am using the nrpe_exporter (https://github.com/RobustPerception/nrpe_exporter) to make about 4500 nrpe client requests every 70s. The nrpe_exporter relies on https://github.com/aperum/nrpe which is a fork of this repo. A few times a day at irregular intervals the nrpe_exporter crashes with the following error:
I believe we see this error because rand.NewSource is not safe for concurrent use, which I found documented at https://pkg.go.dev/math/rand. This PR wraps a mutex around calls to Seed and Uint32. I have not included a test because I cannot think of a way to include a deterministic unit test for this type of error. I did temporarily include a test that I was able to reproduce the issue with on my system, but results would vary across different hardware and OS package versions.
Test I was using:
Output of test: